<template>

	<el-main style="padding:0 20px;">
		<el-descriptions :column="1" border size="small">
			<el-descriptions-item label="请求接口">{{data.url}}</el-descriptions-item>
			<el-descriptions-item label="请求方法">{{data.requestType}}</el-descriptions-item>
			<el-descriptions-item label="日志级别">{{data.level}}</el-descriptions-item>
			<el-descriptions-item label="业务名称">{{data.description}}</el-descriptions-item>
			<el-descriptions-item label="操作时间">{{data.createTime}}</el-descriptions-item>
			<el-descriptions-item label="操作账户">{{data.operatingAccount}}</el-descriptions-item>
			<el-descriptions-item label="入参类型">{{data.requestContentType ? data.requestContentType : '无'}}</el-descriptions-item>
			<el-descriptions-item label="出参类型">{{data.responseContentType}}</el-descriptions-item>
			<el-descriptions-item label="客户端IP">{{data.clientIp}}</el-descriptions-item>
			<el-descriptions-item label="处理耗时">{{data.consumingTime}}ms</el-descriptions-item>
		</el-descriptions>
		<el-collapse v-model="activeNames" style="margin-top: 20px;">
			<el-collapse-item title="常规" name="0">
				<el-alert v-if="data.level" :title="typeMap[data.level].describe" :type="typeMap[data.level].name" :closable="false"></el-alert>
			</el-collapse-item>
			<el-collapse-item title="请求入参" name="1">
				<div class="code">
					{{data.requestParams}}
				</div>
			</el-collapse-item>
			<el-collapse-item title="响应出参" name="2">
				<div class="code">
					{{data.responseParams}}
				</div>
			</el-collapse-item>
			<el-collapse-item title="Header详细" name="3">
				<div class="code">
					Request: {
					<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;User-Agent: {{data.userAgent}},
					<span v-if="data.requestContentType">
					<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Content-Type: {{data.requestContentType}},
					</span>
					<br>},
					<br>Response: {
					<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Content-Type: {{data.responseContentType}},
					<br>}
				</div>
			</el-collapse-item>
		</el-collapse>
	</el-main>
</template>

<script>
	export default {
		data() {
			return {
				data: {
					level: ""
				},
				activeNames: ['0', '1'],
				typeMap: {
					"info": {
						"name":'info',
						"describe": '系统正常响应',
					},
					"warn": {
						"name":'warning',
						"describe": '错误操作',
					},
					"error": {
						"name":'error',
						"describe": '系统错误操作，请联系管理员',
					}
				}
			}
		},
		methods: {
			setData(data){
				this.data = data
			}
		}
	}
</script>

<style scoped>
	.code {background: #848484;padding:15px;color: #fff;font-size: 12px;border-radius: 4px;}
</style>
